import xlwt
import os
#新建一个Excel文件
new_workbook = xlwt.Workbook(encoding='utf-8')
#新建一个sheet
new_sheet = new_workbook.add_sheet('Sheet1')
#写入数据
new_sheet.write(0, 0, 'Hello')
new_sheet.write(0, 1, 'Hello')
# 动态获取保存路径
script_dir = os.path.dirname(os.path.abspath(__file__))
save_path = os.path.join(script_dir, "Excel_xlwt.xls")
#保存文件
new_workbook.save(save_path)
print("写入完成");